package offer;

public class Solution6 {
    int[] res;
    int n;

    public int[] reversePrint(ListNode head) {
        helper(head, 0);
        return res;
    }

    private void helper(ListNode t, int i) {
        if (t == null) {
            n = i;
            res = new int[n];
            return;
        }
        helper(t.next, i + 1);
        res[n - i - 1] = t.val;
    }
}
